#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.57)
AC_INIT(drill, 1.1.0, ldns-team@nlnetlabs.nl, ldns-team)
AC_CONFIG_SRCDIR([13-unit-tests-base.c])

AC_AIX
# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET

# Checks for libraries.
# Checks for header files.
#AC_HEADER_STDC
#AC_HEADER_SYS_WAIT
# do the very minimum - we can always extend this
AC_CHECK_HEADERS([getopt.h stdlib.h stdio.h assert.h netinet/in.hctype.h time.h])
AC_CHECK_HEADERS(sys/param.h sys/mount.h,,,
[
  [
   #if HAVE_SYS_PARAM_H
   # include <sys/param.h>
   #endif
  ]
])

# ssl dir if needed
AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=PATH], [set ssl library directory]),
[
	CPPFLAGS="$CPPFLAGS -I$withval/include"
	LDFLAGS="$LDFLAGS -L$withval -L$withval/lib"
])

# check for ldns
AC_ARG_WITH(ldns, 
	AC_HELP_STRING([--with-ldns=PATH        specify prefix of path of ldns library to use])
	,
	[
		specialldnsdir="$withval"
		CPPFLAGS="$CPPFLAGS -I$withval/include"
		LDFLAGS="$LDFLAGS -L$withval/lib"
	]
)

AC_CHECK_LIB(ldns, ldns_rr_new,, [
	AC_MSG_ERROR([Can't find ldns library])
	]
)

AC_CHECK_HEADER(ldns/ldns.h,,  [
	AC_MSG_ERROR([Can't find ldns headers])
	]
)

AH_BOTTOM([

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>

#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif

#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif

#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif

#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif

#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif

#ifdef HAVE_TIME_H
#include <time.h>
#endif
])


#AC_CHECK_FUNCS([mkdir rmdir strchr strrchr strstr])

#AC_DEFINE_UNQUOTED(SYSCONFDIR, "$sysconfdir")

AC_CONFIG_FILES([13-unit-tests-base.Makefile])
AC_CONFIG_HEADER([config.h])
AC_OUTPUT
